//
//  TDTransaction.m
//  TFB
//
//  Created by yull on 15/8/14.
//  Copyright (c) 2015年 TD. All rights reserved.
//

#import "TDTransaction.h"

@implementation TDTransaction

+ (instancetype)transactionWithDictionary:(NSDictionary *)dic
{
    TDTransaction *transaction = [[TDTransaction alloc] init];
    
    transaction.fee = [dic objectForKey:@"FEE"];
    transaction.netrecamt = [dic objectForKey:@"NETRECAMT"];
    transaction.paytype = [dic objectForKey:@"PAYTYPE"];
    transaction.pay_cardno = [dic objectForKey:@"PAY_CARDNO"];
    transaction.pay_sign_pic = [dic objectForKey:@"PAY_SIGN_PIC"];
    transaction.rate = [dic objectForKey:@"RATE"];
    transaction.rate_type = [dic objectForKey:@"RATE_TYPE"];
    transaction.ter_no = [dic objectForKey:@"TER_NO"];
    transaction.txamt = [dic objectForKey:@"TXAMT"];
    transaction.custId = [dic objectForKey:@"custId"];
    transaction.ordamt = [dic objectForKey:@"ordamt"];
    transaction.ordstatus = [dic objectForKey:@"ordstatus"];
    transaction.ordtime = [dic objectForKey:@"ordtime"];
    transaction.prdordno = [dic objectForKey:@"prdordno"];
    transaction.prdordtype = [dic objectForKey:@"prdordtype"];
    transaction.price = [dic objectForKey:@"price"];
    
    transaction.payordno = [dic objectForKey:@"payordno"];
    
    return transaction;
}

- (NSString *)get_prdordtype_string
{
    if ([self.prdordtype isEqualToString:@"00"]) {
        return @"百货商品";
    } else if ([self.prdordtype isEqualToString:@"01"]) {
        return @"航空公司";
    } else if ([self.prdordtype isEqualToString:@"02"]) {
        return @"大型景区售票";
    }
    
    return @"百货商品";
}

- (NSString *)get_ordtime_format
{
    return [NSString stringWithFormat:@"%@月%@日 %@:%@:%@",
            [self.ordtime substringWithRange:NSMakeRange(4, 2)],
            [self.ordtime substringWithRange:NSMakeRange(6, 2)],
            [self.ordtime substringWithRange:NSMakeRange(8, 2)],
            [self.ordtime substringWithRange:NSMakeRange(10, 2)],
            [self.ordtime substringWithRange:NSMakeRange(12, 2)]];
}

- (NSString *)get_ordstatus_string
{
    //订单状态 00:未交易 01:成功 02:失败 03:可疑 04:处理中 05:已取消 06:未支付 07:已退货 08:退货中 09:部分退货
    if ([self.ordstatus isEqualToString:@"00"]) {
        return @"未支付";
    } else if ([self.ordstatus isEqualToString:@"01"]) {
        return @"交易成功";
    } else if ([self.ordstatus isEqualToString:@"04"]) {
        return @"处理中";
    } else {
        return @"交易失败";
    }
    
    return @"";
}

@end
